<?php

namespace App\Http\Middleware;

use Closure;
use Auth;

class AdminMiddleware
{
    /**
     * Handle an incoming request.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \Closure  $next
     * @return mixed
     */
    public function handle($request, Closure $next)
    {
        // 判断后台用户是否登录,如果没登录,跳转去登录页面,提示请先登录 做了中间件之后去kernel.php中去注册
        if (!Auth::guard('admin')->check()) {
            return redirect()->route('admin.login')->with('error', '请先登录');
        }
        return $next($request);
    }
}
